<?php

namespace Hilaoyu\LaravelExtend\Services\Honeypot;

use Closure;
use Hilaoyu\LaravelExtend\Services\Auth\AuthService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;


class HoneypotMiddleware
{

    public function handle(Request $request, Closure $next)
    {
        if (config('logging.channels.laravel-extend-honeypot')) {
            Log::channel('laravel-extend-honeypot')->info(
                $request->ip()
                . ' ' . $request->method()
                . ' ' . $request->fullUrl()
                , [
                    'ips' => $request->ips(),
                    'userAgent' => $request->userAgent(),
                    'request' => $request->all(),
                    'user' => AuthService::AuthenticatedUser(),
                    'session' => $request->session()->all(),
                ]
            );
        }
        return $next($request);
    }
}
